﻿@using Masuit.MyBlogs.Core.Common
@using Masuit.MyBlogs.Core.Models.DTO
@using Masuit.MyBlogs.Core.Models.Entity
@using Masuit.MyBlogs.Core.Models.ViewModel
@using Masuit.Tools.Core.Net
@model Masuit.MyBlogs.Core.Models.Entity.Notice
@{
    ViewBag.Title = Model.Title;
    Layout = "~/Views/Shared/_Layout.cshtml";
    Random r = new Random();
}
<style>
    .bg-title {
        height: 400px;
        position: relative;
        background: url(/Content/images/@(r.Next(1, 9)).jpg) no-repeat center;
        background-size: cover;
        background-attachment: fixed;
    }
    .header-content {
        position: absolute;
        left: 50%;
        top: 50%;
        transform: translate(-50%, -50%);
    }
    .header-content .divider {
        width: inherit;
        height: 20px;
        margin-top: 20px;
        border-top: 3px solid rebeccapurple;
    }
</style>
<ol class="cd-breadcrumb triangle">
    <li><a asp-controller="Home" asp-action="Index">首页</a></li>
    <li><a asp-controller="Notice" asp-action="Index">公告列表</a></li>
    <li class="current"><em>@ViewBag.Title</em></li>
</ol>
<div class="bg-title">
    <div class="header-content text-center">
        <h1 class="size48">
            @Model.Title
        </h1>
        <div class="divider"></div>
        <p class="size24">
            发布于：@Model.PostDate.ToString("yyyy-MM-dd") | 修改于：@Model.ModifyDate.ToString("yyyy-MM-dd") | 浏览人数：@Model.ViewCount
        </p>
    </div>
</div>
<div class="container">
    <div class="wrapper-content article">
        <div class="ibox">
            <div class="ibox-content">
                <section class="wow fadeInUp">
                    <div class="btn-group">
                        <a asp-controller="Notice" asp-action="Index">&lt;&lt;返回公告列表页</a>
                        @{
                            var user = Context.Session.Get<UserInfoDto>(SessionKey.UserInfo) ?? new UserInfoDto();
                            if (user.IsAdmin)
                            {
                                <a class="btn btn-primary" asp-controller="Dashboard" asp-action="Index" asp-fragment="/notice/index?id=@Model.Id" target="_blank">修改</a>
                            }
                        }
                    </div>
                </section>
                <hr class="margin-top10 marginbot10" />
                <main>
                    <section>
                        <article class="article" id="article">
                            @Html.Raw(await Model.Content.ReplaceImgAttribute(Model.Title))
                        </article>
                    </section>
                </main>
            </div>
        </div>
    </div>
    @{
        await Html.RenderPartialAsync("_ArticleListAdvertisement", (Advertisement)ViewBag.Ads);
    }
</div>
